package com.springboot.config;

import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: TongRui乀
 * @Date: 2020-01-07 14:29
 * @description：
 */
//@Configuration
public class MybatisConfig {

    @Bean
    public SqlSessionFactory sqlSessionFactory(ShardingDataSource shardingDataSource) throws Exception {

        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();

        sqlSessionFactoryBean.setDataSource(shardingDataSource);

        return sqlSessionFactoryBean.getObject();
    }

}
